package org.ahuanlien.crm.service.impl;

import org.ahuanlien.crm.domain.Dictionary;
import org.ahuanlien.crm.mapper.DictionaryMapper;
import org.ahuanlien.crm.service.IDictionaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DictionaryServiceImpl implements IDictionaryService {

	@Autowired
	private DictionaryMapper dictionaryMapper;


	public void saveOrUpdate(Dictionary record) {
		if (record.getId() != null) {
			dictionaryMapper.updateByPrimaryKey(record);
		} else {
			dictionaryMapper.insert(record);
		}
	}

	public void deleteByPrimaryKey(Long id) {
		dictionaryMapper.deleteByPrimaryKey(id);
	}

	public List<Dictionary> selectRootDictionary() {
		return dictionaryMapper.selectRootDictionary();
	}

	public List<Dictionary> selectDictionaryItemBySn(String sn) {
		return dictionaryMapper.selectDictionaryItemBySn(sn);
	}

	public void saveOrUpdateSn(Dictionary record) {
		if (record.getId() != null) {
			dictionaryMapper.updateByPrimaryKeySn(record);
		} else {
			dictionaryMapper.insertSn(record);
		}
	}

	public void deleteByPrimaryKeySn(Long id) {
		dictionaryMapper.deleteByPrimaryKeySn(id);
	}

	public Dictionary selectDictionaryItemById(Long id) {
		return dictionaryMapper.selectDictionaryItemById(id);
	}
}
